<div class="fm-content">
  <div class="title">
    <i nz-icon [type]="'desktop'"></i> &nbsp;&nbsp;叠加分析
  </div>
  <div class="work">
    <div class="top">
      <input nz-input placeholder="名称" class="fm-input first-input" [(ngModel)]="fs.queryObject['name:like']" />

      <nz-button-group class="fm-search-input">
        <button nz-button nzType="primary" (click)="fs.loadData(true)">查询</button>
        <button nz-button (click)="fs.resetQueryObject() && fs.loadData(true)">重置</button>
      </nz-button-group>
      <div class="tool-right">
        <nz-button-group>
          <button nz-button [nzType]="'primary'" (click)="fs.addRow()">新增</button>
          <button nz-button (click)="fs.editRow()">编辑</button>
          <button nz-popconfirm nzTitle="确认删除选择项?" (nzOnConfirm)="fs.delEntitys()" nzPlacement="bottomRight"
            nz-button>删除</button>
        </nz-button-group>
      </div>
    </div>

    <div class="work-content">
      <div class="table">
        <nz-table nzSize="middle" nzShowSizeChanger
          [nzPageSizeOptions]='[ 10, 15, 20, 30, 40, 50 ]' [nzFrontPagination]="false" [nzData]="fs.datas"
          [nzLoading]="fs.isLoading || fs.isDeleing" [nzTotal]="fs.rowsCount" [(nzPageIndex)]="fs.pageIndex"
          [(nzPageSize)]="fs.pageSize" (nzPageIndexChange)="fs.loadData()" (nzPageSizeChange)="fs.loadData(true)">
          <thead (nzSortChange)="fs.sort($event)" nzSingleSort>
            <tr>
              <th nzShowCheckbox [(nzChecked)]="fs.allChecked" [nzIndeterminate]="fs.indeterminate"
                (nzCheckedChange)="fs.checkAll($event)"></th>
              <th>名称</th>
              <th>类型</th>
              <th>终端类型</th>
              <th>元数据</th>
              <th>有效</th>
            </tr>
          </thead>
          <tbody>
            <tr *ngFor="let data of fs.datas">
              <td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="fs.refreshCheckStatus()">
              </td>
              <td (click)="fs.editRow(data)" class="form-edit">{{data.name}}</td>
              <td>{{data.typeName}}</td>
              <td>{{data.terminalName}}</td>
              <td>{{data.medalianame}}</td>
              <td>{{data.valid | boolReform}}</td>
            </tr>
          </tbody>
        </nz-table>
      </div>
    </div>

    <nz-modal nzWidth='830' nzTitle="编辑" [nzMaskClosable]='false' [nzFooter]="null" [(nzVisible)]="fs.isEditVisible"
      (nzOnCancel)="fs.closeEdit()">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">名称</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="name.invalid?'error':'success'" nzHasFeedback>
                <input nz-input required [(ngModel)]="fs.er.name" id="name" name="name" #name="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">类型</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="type.invalid?'error':'success'" nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.type" name="type" required #type="ngModel"
                  (nzOpenChange)="layerType.load('0')" [nzPlaceHolder]="'请选择'">
                  <ng-container *ngFor="let option of layerType.datas">
                    <nz-option *ngIf="option.id == '11' || option.id == '13' || option.id == '21' || option.id == '23'"
                      [nzLabel]="option.display" [nzValue]="option.id">
                    </nz-option>
                  </ng-container>
                  <nz-option *ngIf="layerType.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>
                  <span *ngIf="!layerType.isLoaded">
                    <nz-option [nzLabel]="fs.er.typeName" [nzValue]="fs.er.type">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">地址</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="layerId.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input required [(ngModel)]="fs.er.layerId" name="layerId" #layerId="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">服务名称</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="serviceName.invalid?'error':'success'"
                nzHasFeedback>
                <input nz-input required [(ngModel)]="fs.er.serviceName" name="serviceName" #serviceName="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">空间字段</nz-form-label>
              <nz-form-control class="form-control">
                <input nz-input [(ngModel)]="fs.er.geoField" name="geoField" #geoField="ngModel">
              </nz-form-control>
            </nz-form-item>
          </div>
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">元数据</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="medname.invalid?'error':'success'"
                nzHasFeedback>
                <!-- <nz-tree-select class="form-control" required #medname="ngModel" [(ngModel)]="fs.er.medname"
                  name="medname" nzPlaceHolder="请选择" [nzDropdownMatchSelectWidth]="true"
                  [nzDropdownStyle]="{ 'max-height': '300px' }" [nzAsyncData]="true" [nzNodes]="metaDic.treeDatas"
                  (nzOpenChange)="metaDic.load('0')" (nzExpandChange)="metaDic.expand($event)">
                </nz-tree-select> -->
                <nz-tree-select required class="form-control" [(ngModel)]="fs.er.medname" name="medname"
                  #medname="ngModel" nzPlaceHolder="请选择" [nzDropdownMatchSelectWidth]="true"
                  [nzDropdownStyle]="{ 'max-height': '300px' }" [nzAsyncData]="true" [nzNodes]="metaDic.treeDatas"
                  (nzExpandChange)="metaDic.expand($event)">
                </nz-tree-select>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">查询集</nz-form-label>
              <nz-form-control class="form-control">
                <nz-input-number [(ngModel)]="fs.er.queryLayerId" name="queryLayerId" [nzMin]="0" [nzStep]="1"
                  class="form-control">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>

          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">排序</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="order.invalid?'error':'success'" nzHasFeedback>
                <nz-input-number required [(ngModel)]="fs.er.order" name="order" [nzMin]="1" [nzStep]="1"
                  class="form-control" #order="ngModel">
                </nz-input-number>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>

        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label nzRequired class="form-label">终端类型</nz-form-label>
              <nz-form-control class="form-control" [nzValidateStatus]="terminal.invalid?'error':'success'"
                nzHasFeedback>
                <nz-select [(ngModel)]="fs.er.terminal" name="terminal" required #terminal="ngModel"
                  (nzOpenChange)="terminalType.load('0')" [nzPlaceHolder]="'请选择'">
                  <ng-container *ngFor="let option of terminalType.datas">
                    <nz-option [nzLabel]="option.display" [nzValue]="option.id">
                    </nz-option>
                  </ng-container>

                  <nz-option *ngIf="terminalType.isLoading" nzDisabled nzCustomContent>
                    <i nz-icon type="loading" class="loading-icon"></i>加载中...
                  </nz-option>

                  <span *ngIf="!terminalType.isLoaded">
                    <nz-option [nzLabel]="fs.er.terminalName" [nzValue]="fs.er.terminal">
                    </nz-option>
                  </span>
                </nz-select>
              </nz-form-control>
            </nz-form-item>
          </div>


          <div nz-col [nzSpan]="12">
            <nz-form-item>
              <nz-form-label class="form-label">有效</nz-form-label>
              <nz-form-control class="form-control">
                <nz-switch nzCheckedChildren="是" nzUnCheckedChildren="否" [(ngModel)]="fs.er.valid" name="valid">
                </nz-switch>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24">
            <nz-form-item>
              <nz-form-label class="form-label">属性</nz-form-label>
              <nz-form-control class="form-control3">
                <nz-tabset nzSize="small">
                  <nz-tab nzTitle="统计分类">
                    <nz-transfer [nzDataSource]="categorys" (nzChange)="change($event)" [nzTitles]="['数据结构', '统计分类']"
                      [nzListStyle]="{ 'width.px': 260 }">
                    </nz-transfer>
                  </nz-tab>
                  <nz-tab nzTitle="统计内容">
                    <nz-transfer [nzDataSource]="statistics" (nzChange)="change($event)" [nzTitles]="['数据结构', '统计内容']"
                      [nzListStyle]="{ 'width.px': 260 }">
                    </nz-transfer>
                  </nz-tab>
                  <nz-tab nzTitle="显示内容">
                    <nz-transfer [nzDataSource]="shows" (nzChange)="change($event)" [nzTitles]="['数据结构', '显示内容']"
                      [nzListStyle]="{ 'width.px': 260 }">
                    </nz-transfer>
                  </nz-tab>
                </nz-tabset>
              </nz-form-control>
            </nz-form-item>
          </div>
        </div>
        <div nz-row [nzGutter]="24">
          <div nz-col [nzSpan]="24" class="form-button-align">
            <button nz-button nzType="default" (click)="fs.closeEdit()" class="form-button">取消</button>
            <button nz-button nzType="primary"
              [disabled]='name.invalid || type.invalid || layerId.invalid || order.invalid || medname.invalid'
              (click)="save()" [nzLoading]="fs.isSaveing">保存</button>
          </div>
        </div>
      </form>
    </nz-modal>
  </div>
</div>